package org.hzz.application.command.user;

import io.gitee.pkmer.common.util.StrUtil;
import io.gitee.pkmer.ddd.shared.command.CommandWithMark;
import io.gitee.pkmer.ddd.shared.service.CmdService;
import lombok.Data;
import lombok.Value;
import lombok.experimental.Accessors;
import org.hzz.application.handler.user.ReceiveCouponCmdHandler;

/**
 * @author <a href="mailto:1193094618@qq.com">pkmer</a>
 * <br>
 * <a href = "https://gitee.com/developeros/videos-online">Code Repository</a>
 * At 2024/9/2
 * 用户领取优惠券命令
 * {@link ReceiveCouponCmdHandler}
 */
@Data
@Accessors(chain = true)
public class ReceiveCouponCmd implements CommandWithMark {
    public static final String MARK = ReceiveCouponCmd.class.getName();

    Long userId;
    Long couponId;
    String code;
    Integer serialNum;
    boolean isHandleCode = false;

    @Override
    public String mark() {
        return MARK;
    }


    @Override
    public void execute(CmdService cmdService) {
        isHandleCode = !StrUtil.isEmpty(code) && couponId == null;
        CommandWithMark.super.execute(cmdService);
    }
}
